package com.example.address.service;

import lombok.Getter;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

@Getter
public class ConfigurationAws {
    private final AwsCredentialsProvider provider;

    private final Region region;

    private final String placeIndex;

    private final String placeApiKey;

    public ConfigurationAws() {
        Properties AWSproperties = new Properties();
        try (InputStream input =
                     new FileInputStream("src/main/resources/aws/aws-config.properties")
        ) {
            AWSproperties.load(input);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        region = Region.of(AWSproperties.getProperty("Region"));
        AwsBasicCredentials credentials =
                AwsBasicCredentials.create(AWSproperties.getProperty("AccessKeyId"),
                        AWSproperties.getProperty("SecretAccessKey"));
        provider = StaticCredentialsProvider.create(credentials);
        placeIndex = AWSproperties.getProperty("PlaceIndex");
        placeApiKey = AWSproperties.getProperty("PlaceApikey");
    }


}
